//
//  IMIMediaFrameworkProtocol.h
//  MiHome
//
//  Created by 阎超 on 10/05/2017.
//  Copyright © 2017 小米移动软件. All rights reserved.
//

#ifndef IMIMediaFrameworkProtocol_h
#define IMIMediaFrameworkProtocol_h

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, IMIDecoderType) {
    IMIDecoderType_FFmpegSoftDecode = 0,//FFmpeg软解码
    IMIDecoderType_FFmpegSoftDecodePOC,//FFmpeg解码带POC检验
    IMIDecoderType_MStarSoftDecode,//MStar软解码
    IMIDecoderType_iOSHardDecode,//iOS硬解码
};

typedef NS_ENUM(NSInteger, IMIEnhanceRenderAlgoType) {
    IMIEnhanceRenderAlgoType_EnableLensCorrent = 0,
    IMIEnhanceRenderAlgoType_EnableLensCorrentOSD,
    IMIEnhanceRenderAlgoType_DisableLensCorrent,
    IMIEnhanceRenderAlgoType_EnableLensCorrentOSD_021E01
};

@class IMIMediaFrame;
typedef void (^ fMediaStreamDataBlock)(id usrData, IMIMediaFrame* frame, id other);
typedef void (^ fAsyncCaptureBlock)(UIImage* image);

@protocol IMIPluginBaseProtocol <NSObject>
@optional
- (instancetype)initWithFlag:(NSInteger)flag;
- (void)fini;
- (NSInteger)putSomething:(NSString*)name withValue:(id)value;
- (NSInteger)getSomething:(NSString*)name withValue:(id)value;
@end

@protocol IMIPluginEventProtocol <NSObject>
@optional
- (void)videoDynamicTransformationEvent:(NSInteger)width andHeight:(NSInteger)height;
- (void)audioDynamicTransformationEvent;
@end

@protocol IMISourceBaseProtocol <IMIPluginBaseProtocol, IMIPluginEventProtocol>
@optional
- (NSInteger)intputFrame:(IMIMediaFrame*)frame;
- (IMIMediaFrame*)getFrame;
@end

@protocol IMICodecBaseProtocol <IMIPluginBaseProtocol, IMIPluginEventProtocol>
@required
- (NSInteger)transformFrame:(IMIMediaFrame*)inFrame withResult:(IMIMediaFrame*)outFrame;
- (NSInteger)setDecoderType:(IMIDecoderType)type;
@end

@protocol IMIOutputBaseProtocol <IMIPluginBaseProtocol, IMIPluginEventProtocol>
@required
- (NSInteger)setTerminal:(id)terminal;
- (NSInteger)refresh:(id)param;
- (NSInteger)outputFrame:(IMIMediaFrame*)frame withTime:(NSInteger)time;
- (UIImage*)snapshotPicture;
- (NSInteger)enhanceRender:(IMIEnhanceRenderAlgoType)algoType;
@end

@protocol IMIPipelineBaseProtocol <IMIPluginBaseProtocol>
@required
- (NSInteger)startVideoPlayer:(id)terminal withDecodeBloack:(fMediaStreamDataBlock)fBlock;
- (NSInteger)stopVideoPlayer;
- (NSInteger)startAudioPlayer:(id)terminal withDecodeBloack:(fMediaStreamDataBlock)fBlock;
- (NSInteger)stopAudioPlayer;
- (NSInteger)startTalk:(fMediaStreamDataBlock)fBlock;
- (NSInteger)stopTalk;
- (NSInteger)deliverFrame:(IMIMediaFrame*)frame;
- (UIImage*)snapshotPicture:(fAsyncCaptureBlock)fBlock;
- (void)play:(id)terminal;
- (void)pause;
- (NSInteger)getCurrentPosition;
@end

#endif /* IMIMediaFrameworkProtocol_h */
